﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
	xmlns:esriConverters="clr-namespace:ESRI.ArcGIS.Client.ValueConverters;assembly=ESRI.ArcGIS.Client">

	<esriConverters:MultiplicationConverter x:Key="multiplicationConverter" />
	<esriConverters:DoubleCollectionCloner x:Key="doubleCollectionCloner"/>
	<esriConverters:DictionaryConverter x:Key="DictConvert" />

	<!--GraphicGroupElement-->
	<ControlTemplate x:Key="GraphicGroupElement"><Canvas x:Name="Canvas" /></ControlTemplate>

	<!--Marker Symbols-->

	<ControlTemplate x:Key="SimpleMarkerSymbol_Circle">
		<Ellipse x:Name="ellipse" IsHitTestVisible="False"
			RenderTransformOrigin="0.5,0.5" 
			Fill="{Binding Symbol.Color}"
			Width="{Binding Symbol.Size}"
			Height="{Binding Symbol.Size}" >
			<vsm:VisualStateManager.VisualStateGroups>
				<vsm:VisualStateGroup x:Name="CommonStates">
					<vsm:VisualState x:Name="Normal">
						<Storyboard>
							<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1" Duration="0:0:0.1" />
							<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.1" />
						</Storyboard>
					</vsm:VisualState>
					<vsm:VisualState x:Name="MouseOver">
						<Storyboard>
							<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.25" Duration="0:0:0.1" />
							<DoubleAnimation BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.25" Duration="0:0:0.1" />
						</Storyboard>
					</vsm:VisualState>
				</vsm:VisualStateGroup>
			</vsm:VisualStateManager.VisualStateGroups>
			<Ellipse.RenderTransform>
				<ScaleTransform ScaleX="1" ScaleY="1" />
			</Ellipse.RenderTransform>
		</Ellipse>
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleMarkerSymbol_Cross">
		<Grid Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}" RenderTransformOrigin="0.5,0.5">
			<Rectangle Height="1" Fill="{Binding Symbol.Color}" VerticalAlignment="Center" />
			<Rectangle Width="1" Fill="{Binding Symbol.Color}" HorizontalAlignment="Center" />
		</Grid>
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleMarkerSymbol_Diamond">
		<Rectangle RenderTransformOrigin="0.5,0.5"
			Fill="{Binding Symbol.Color}"
			Width="{Binding Symbol.Size}"
			Height="{Binding Symbol.Size}" >
			<Rectangle.RenderTransform>
				<RotateTransform Angle="45" />
			</Rectangle.RenderTransform>
		</Rectangle>
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleMarkerSymbol_Square">
		<Rectangle RenderTransformOrigin="0.5,0.5"
			Fill="{Binding Symbol.Color}"
			Width="{Binding Symbol.Size}"
			Height="{Binding Symbol.Size}" >
		</Rectangle>
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleMarkerSymbol_Triangle">
		<TextBlock Text="▲" RenderTransformOrigin="0.5,0.5" FontFamily="Arial" FontSize="{Binding Path=Symbol.Size, Converter={StaticResource multiplicationConverter}, ConverterParameter=1.5, Mode=OneWay}" Foreground="{Binding Symbol.Color}" />
	</ControlTemplate>

	<ControlTemplate x:Key="TextSymbol">
		<TextBlock Text="{Binding Symbol.Text}" 
			FontFamily="{Binding Symbol.FontFamily}"
			FontSize="{Binding Symbol.FontSize}"
			Foreground="{Binding Symbol.Foreground}" />
	</ControlTemplate>

	<ControlTemplate x:Key="PictureMarkerSymbol">
		<Image Source="{Binding Symbol.Source}"
			Opacity="{Binding Symbol.Opacity}"
			Stretch="Fill"
			Width="{Binding Symbol.Width}"
			Height="{Binding Symbol.Height}" />
	</ControlTemplate>

	<ControlTemplate x:Key="ClusterSymbol">
		<Grid>
			<Ellipse 
				Fill="{Binding Path=Attributes, Converter={StaticResource DictConvert}, ConverterParameter=Color, Mode=OneWay}" 
				Width="{Binding Path=Attributes, Converter={StaticResource DictConvert}, ConverterParameter=Size, Mode=OneWay}"
				Height="{Binding Path=Attributes, Converter={StaticResource DictConvert}, ConverterParameter=Size, Mode=OneWay}" />
			<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
				Text="{Binding Path=Attributes, Converter={StaticResource DictConvert}, ConverterParameter=Count, Mode=OneWay}" 
				FontSize="9" Margin="1,1,0,0" FontWeight="Bold"
				Foreground="#99000000" />
			<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
				Text="{Binding Path=Attributes, Converter={StaticResource DictConvert}, ConverterParameter=Count, Mode=OneWay}" 
				FontSize="9" Margin="0,0,1,1" FontWeight="Bold"
				Foreground="White" />
		</Grid>
	</ControlTemplate>
	
	<!--Fill Symbols-->

	<ControlTemplate x:Key="FillSymbol">
		<Path x:Name="Element" IsHitTestVisible="False"
			Stroke="{Binding Symbol.BorderBrush}"
			StrokeStartLineCap="Round"
			StrokeThickness="{Binding Symbol.BorderThickness}"
			StrokeLineJoin="Round"
			StrokeEndLineCap="Round"
			Fill="{Binding Symbol.Fill}" />
	</ControlTemplate>

	<!--Line Symbols-->

	<ControlTemplate x:Key="LineSymbol">
		<Path x:Name="Element" IsHitTestVisible="False"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="Round"
			StrokeStartLineCap="Round"
			StrokeLineJoin="Round"
			StrokeEndLineCap="Round"/>
	</ControlTemplate>

	<ControlTemplate x:Key="CartographicLineSymbol">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="{Binding Symbol.DashCap}"
			StrokeStartLineCap="{Binding Symbol.StartLineCap}"
			StrokeLineJoin="{Binding Symbol.LineJoin}"
			StrokeEndLineCap="{Binding Symbol.EndLineCap}"
			StrokeDashOffset="{Binding Symbol.DashOffset}"
			StrokeDashArray="{Binding Path=Symbol.DashArray, Converter={StaticResource doubleCollectionCloner}}"/>
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_Dash">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="Flat"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeDashArray="5,1" />
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_DashDot">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="Flat"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeDashArray="2,1,1,1" />
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_DashDotDot">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="Flat"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeDashArray="2,1,1,1,1,1" />
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_Dot">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeThickness="{Binding Symbol.Width}"
			StrokeDashCap="Flat"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeDashArray="1,1" />
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_Null">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeThickness="{Binding Symbol.Width}" />
	</ControlTemplate>

	<ControlTemplate x:Key="SimpleLineSymbol_Solid">
		<Path x:Name="Element"
			Stroke="{Binding Symbol.Color}"
			StrokeStartLineCap="Flat"
			StrokeEndLineCap="Flat"
			StrokeLineJoin="Round"
			StrokeThickness="{Binding Symbol.Width}"
		/>
	</ControlTemplate>
</ResourceDictionary>
